//
//  StatusToolBar.m
//  Weibo
//
//  Created by Anasue on 9/16/15.
//  Copyright (c) 2015 Anasue. All rights reserved.
//

#import "StatusToolBar.h"
#import "Status.h"

@interface StatusToolBar ()
@property (nonatomic, strong) NSMutableArray *dividers;

@end

@implementation StatusToolBar

- (NSMutableArray *)dividers
{
    if (_dividers == nil) {
        _dividers = [NSMutableArray array];
    }
    return _dividers;
}

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self seupDivider];
        [self seupDivider];
    }
    return self;
}

/**
 *  创建分割线
 */
- (void)seupDivider
{
    UIImageView *divider = [[UIImageView alloc]init];
    divider.image = [UIImage imageWithName:@"timeline_card_bottom_line"];
    divider.contentMode = UIViewContentModeCenter;
    [self addSubview:divider];
    [self.dividers addObject:divider];
}

/**
 *  按钮的位置
 */
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //分割线位置
    NSInteger dividerCount = self.dividers.count;
    CGFloat dividerFirsrtX = self.size.width / (dividerCount + 1);
    for (int i = 0; i < dividerCount; i ++) {
        UIImageView *divider = self.dividers[i];
        divider.x = (i + 1) * dividerFirsrtX;
        divider.width = 1;
        divider.height = self.height;
        divider.y = divider.height * 0.5;
    }
}

- (void)drawRect:(CGRect)rect
{
    [[UIImage resizeImage:@"common_card_bottom_background"]drawInRect:rect];
}


@end
